package route

import (
	"CRM_rorm/logic/ClientLogic"
	"CRM_rorm/logic/CompanyLogic"
	"CRM_rorm/logic/ProjectLogic"
	"CRM_rorm/logic/Project_MemberLogic"
	"CRM_rorm/logic/StaffLogic"
	"CRM_rorm/middleware"
	"github.com/gin-gonic/gin"
)

func CollectRoute(r *gin.Engine) *gin.Engine {
	r.Use(middleware.CORSMiddleware(), middleware.RecoverMiddleware()) //使用中间件
	v1 := r.Group("/CRM")
	{
		v1.POST("/register", StaffLogic.StaffRegister)

		v22 := v1.Group("/login")
		{
			v22.POST("/UserLogin", StaffLogic.StaffLogin)

			v31 := v22.Group("/company", middleware.AuthMiddleware())
			{
				v31.POST("/add", CompanyLogic.CompanyAdd)
				v31.POST("/delete", CompanyLogic.CompanyDelete)
				v31.POST("/DeleteSoft", CompanyLogic.CompanyDeleteSoft)
				v31.POST("/update", CompanyLogic.CompanyUpdate)
				v31.POST("/find", CompanyLogic.CompanyFind)
			}
			v32 := v22.Group("/staff", middleware.AuthMiddleware())
			{
				v32.POST("/delete", StaffLogic.StaffDelete)
				v32.POST("/DeleteSoft", StaffLogic.StaffDeleteSoft)
				v32.POST("/update", StaffLogic.StaffUpdate)
				v32.POST("/FindOneByStaffId", StaffLogic.StaffFindOneByStaffId)
				v32.POST("/FindOneByProjectId", StaffLogic.StaffFindOneByProjectId)
			}
			v33 := v22.Group("/client", middleware.AuthMiddleware())
			{
				v33.POST("/add", ClientLogic.ClientAdd)
				v33.POST("/delete", ClientLogic.ClientDelete)
				v33.POST("/DeleteSoft", ClientLogic.ClientDeleteSoft)
				v33.POST("/update", ClientLogic.ClientUpdate)
				v33.POST("/FindOneByClientId", ClientLogic.ClientFindByClientId)
				v33.POST("/FindOneByProjectId", ClientLogic.ClientFindByProjectId)

			}
			v34 := v22.Group("/project", middleware.AuthMiddleware())
			{
				v34.POST("/add", ProjectLogic.ProjectAdd)
				v34.POST("/delete", ProjectLogic.ProjectDelete)
				v34.POST("/DeleteSoft", ProjectLogic.ProjectDeleteSoft)
				v34.POST("/update", ProjectLogic.ProjectUpdate)
				v34.POST("/FindOneByProjectId", ProjectLogic.ProjectFind)
			}
			v35 := v22.Group("/Project_Member", middleware.AuthMiddleware())
			{
				v35.POST("/add", Project_MemberLogic.ProjectMemberAdd)
				v35.POST("/delete", Project_MemberLogic.ProjectMemberDelete)
				v35.POST("/DeleteSoft", Project_MemberLogic.ProjectMemberDeleteSoft)
				v35.POST("/update", Project_MemberLogic.ProjectMemberUpdate)
				v35.POST("/FindOneByMemberId", Project_MemberLogic.ProjectMemberFind)
			}
		}

	}
	return r
}
